#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""  
@Project : pythonProject
@File : mysql_val.py
@Author : 孔雀
@Time : 2025/9/2 14:30  
@脚本说明 : 

"""
import threading

import pymysql


def scan_mysql(host="127.0.0.1", port=3306, user="root", password="", connect_timeout=5):
    try:
        pymysql.connect(
            host=host,
            port=port,
            user=user,
            password=password,
            connect_timeout=connect_timeout,
            database="information_schema",
            charset="utf8",
            autocommit=True,
        )
        print(f"[+] {host}:{port} 存在MySQL数据库弱口令 -> {user} / {password}")
    except:
        pass


def mysql_run(host, port, users, passwds):
    try:
        threads = []
        for user in users:
            # 读取密码字典
            for passwd in passwds:
                # 弱口令扫描 注意需要去除空白符
                t = threading.Thread(target=scan_mysql, args=(host, port, user.strip(), passwd.strip()))
                t.start()
                threads.append(t)
        for t in threads:
            t.join()
    except:
        pass
